from multiprocessing import Queue, Process
from time import sleep


def write(q):
    for i in range(10):
        q.put_nowait(i)
        print('存入数据：',i)
        sleep(0.1)

def read(q):

    while True:
        if not q.empty():
            print('取出数据：',q.get_nowait())

        else:
            break
if __name__ == '__main__':
    #获取队列对象
    q = Queue()
    #创建进程
    p1 = Process(target=write,args=(q,))
    p1.start()
    p1.join()

    p2 = Process(target=read,args=(q,))
    p2.start()
    p2.join()